<?=$this->header()?>


    <?=$this->menu("staff")?>


    <h1><?=$this->message("nav.staff")?></h1>


    <? /* Breadcrums route & staff info display */ ?>
    <?=$this->route(
        $this->message("nav.staff"),                    // Route display
        $this->staffListForm,                           // ListForm (for staff info, see float right)
        $this->staffs($this->staffListForm)->getRows()) // The total amount of staffs
    ?>


    <? /* Show status messages */ ?>
    <?=$this->messages(_Core::BUNDLE)?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null)?>


    <form id="<?=get_class($this->staffListForm)?>"
          method="post"
          action="staff/list"
          onsubmit="return confirmDelete('<?=$this->message("message.confirm.delete", _Core::BUNDLE)?>', this)">


        <? /* Show the Search & Filter Panel */ ?>
        <?=$this->panel(
            "staff/edit",         // Add New URL
            $this->staffListForm, // ListForm
            array(                // Filter fields
                StaffPeer::FIRSTNAME=>$this->message("prompt.firstname", _Staff::BUNDLE),
                StaffPeer::SURNAME=>$this->message("prompt.surname", _Staff::BUNDLE),
                StaffPeer::REGION=>$this->message("prompt.region", _Staff::BUNDLE),
                StaffPeer::ORGANIZATION=>$this->message("prompt.organization", _Staff::BUNDLE),
                LanguagePeer::NAME=>$this->message("prompt.language", _Staff::BUNDLE),
                StaffPeer::USERNAME=>$this->message("prompt.username", _Staff::BUNDLE),
                StaffRolePeer::ROLENAME=>$this->message("prompt.role", _Staff::BUNDLE),
                StaffPeer::INSERT_DATE=>$this->message("choose.created", _Core::BUNDLE),
                StaffPeer::MODIFIED_DATE=>$this->message("choose.modified", _Core::BUNDLE),
                StaffPeer::ACTIVE=>$this->message("choose.active", _Core::BUNDLE),
            ),
            false // No languages for this page.
        )?>


        <? /* Start output buffering in case there are no results */ ?>
        <?$this->start()?>


        <table class="list" cellspacing="0" cellpadding="0">
        <tr>
            <th class="checkbox"></th>
            <th class="narrow"></th>
            <th class="narrow" title="<?=$this->message("prompt.language", _Staff::BUNDLE)?>">
                <?=$this->TH(
                    $this->staffListForm,                     // ListForm
                    StaffPeer::LANGUAGE_CODE,                  // Sort Field
                    $this->message("label.language", _Staff::BUNDLE) // Header Name
                )?>
            </th>
            <th>
                <?=$this->TH(
                    $this->staffListForm,                     // ListForm
                    StaffPeer::SURNAME,                        // Sort Field
                    $this->message("prompt.surname", _Staff::BUNDLE) // Header Name
                )?>
            </th>
            <th>
                <?=$this->TH(
                    $this->staffListForm,                       // ListForm
                    StaffPeer::FIRSTNAME,                        // Sort Field
                    $this->message("prompt.firstname", _Staff::BUNDLE) // Header Name
                )?>
            </th>
            <th>
                <?=$this->TH(
                    $this->staffListForm,                      // ListForm
                    StaffPeer::USERNAME,                        // Sort Field
                    $this->message("prompt.username", _Staff::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->staffListForm,             // ListForm
                    StaffPeer::MODIFIED_DATE,          // Sort Field
                    $this->message("choose.modified", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->staffListForm,            // ListForm
                    StaffPeer::INSERT_DATE,           // Sort Field
                    $this->message("choose.created", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->staffListForm,          // ListForm
                    StaffPeer::ACTIVE,              // Sort Field
                    $this->message("label.active", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="buttons"></th>
        </tr>

        <? foreach($this->staffs($this->staffListForm)->getItems() as $staff) { ?>

            <? /* Display the default language staff */ ?>
            <tr class="ctrl">
                <td class="checkbox">
                    <input type="checkbox"
                           name="items[]"
                           value="<?=$staff->getStaffId()?>"
                           <?=in_array($staff->getStaffId(), $this->staffListForm->getItems()) ? " checked=\"checked\"" : ""?> />

                </td>
                <td>
                    <? if($staff->getImageId() > 0): ?>
                    <a title="<?=$this->message("title.image", _Core::BUNDLE)?>" href="image?id=<?=$staff->getImageId()?>">
                        <?=$this->thumbnail($staff->getThumbnailId())?>
                    </a>
                    <? endif; ?>
                </td>
                <td title="Preferred Language">

                    <img src="static.php?file=<?=$this->image("cms/core/view/gfx/flag/".strtolower($staff->getLanguageCode()).".png")?>"
                         width="16" height="11" alt="<?=$staff->getLanguage()->getName()?>"
                         title="<?=$staff->getLanguage()->getName()?>" class="flag" />

                </td>
                <td><?=$staff->getSurname()?></td>
                <td><?=$staff->getFirstname()?></td>
                <td title="<?=$this->message("label.email", _Staff::BUNDLE)?>">
                    <a href="mailto:<?=$staff->getUserName()?>">
                        <?=$this->truncateNicely($staff->getUserName(), 10, 16, "...")?>
                    </a>
                </td>
                <td title="<?=$this->message("title.modified", _Core::BUNDLE)?> <?=$staff->getModifiedDate(_Core::FORMAT_DATETIME)?>">
                    <?=$staff->getModifiedDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.created", _Core::BUNDLE)?> <?=$staff->getInsertDate(_Core::FORMAT_DATETIME)?>">
                    <?=$staff->getInsertDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                    <?=$this->message("label." . ($staff->getActive() ? "yes" : "no"), _Core::BUNDLE)?>
                </td>
                <td class="buttons">

                    <input type="button"
                           onclick="to('staff/edit?staff->staffId=<?=$staff->getStaffId()?>')"
                           class="button"
                           value="<?=$this->message("button.edit", _Core::BUNDLE)?>" />

                    <input type="button"
                           onclick="del(<?=$staff->getStaffId()?>, '<?=get_class($this->staffListForm)?>')"
                           class="button"
                           value="<?=$this->message("button.delete", _Core::BUNDLE)?>" />

                </td>
            </tr>

        <? } ?>

        </table>


        <? /* Edit/Action Bar for checkboxed */ ?>
        <?=$this->edit(
            $this->staffListForm, // ListForm
            array(                // The actions
                "activate"=>$this->message("choose.activate", _Core::BUNDLE),
                "deactivate"=>$this->message("choose.deactivate", _Core::BUNDLE),
                "delete"=>$this->message("choose.delete", _Core::BUNDLE)
            )
        )?>


        <? /* End output buffering */ ?>
        <?$this->end(
            $this->staffListForm,                         // ListForm
            $this->path()."staff/edit",                   // Add New URL
            $this->staffs($this->staffListForm)->getRows() // The total amount of staffs
        )?>


    </form>

<?=$this->footer()?>